<div class="left-sidebar">
    <div class="logo">
        <img src="${base}/res/images/logo.png">
    </div>
    <ul class="nav-menu" id="mainNav">
        <li><a href="/admin/home"><span class="glyphicon glyphicon-th"></span> 首页</a></li>
    </ul>

    <div class="user-box">
        <div class="company-info" id="companyDiv" style="display: none;">-</div>

        <a href="javascript:void(0)" data-field="account-name">-</a>
        |
        <a href="${base}/admin/member">个人中心</a>
        |
        <a href="javascript:logout()">退出</a>
    </div>

    <script type="text/javascript">
        $(document).ready(function () {
            var account = getUserAccount();
            var ctx = $('#base').val();
            if (account.company) {
                var company = $('#companyDiv');
                company.text(account.company.unitName);
                company.show();
            }
            $(account.resources).each(function () {
                if (this.type === 'MENU') {
                    if (this.fid === -1) {
                        var html = '<li><a href="' + ctx + '/' + this.path + '"><span class="glyphicon '
                            + this.icon + '"></span> ' + this.displayName + '</a></li>';
                        $('#mainNav').append(html);
                    }
                }
            });
        });

        function logout() {
            bootbox.confirm({
                message: "是否确认注销?",
                buttons: {
                    confirm: {
                        label: '是',
                        className: 'btn-success'
                    },
                    cancel: {
                        label: '否',
                        className: 'btn-danger'
                    }
                },
                callback: function (result) {
                    if (result) {
                        $.httpclient.post(API_MEMBER + '/' + "logout", null, function (data) {
                            if (data.code === 'SUCCESS') {
                                location.href = '/';
                            } else {
                                bootbox.alert(data.message);
                            }

                        })
                    }
                }
            });
        }
    </script>
</div>